<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">

    <ui:composition template="/template.xhtml">

        <ui:define name="title">
            <h:outputText value="#{bundle.ListBillTitle}"></h:outputText>
        </ui:define>

        <ui:define name="body">
            <h:outputScript name="js/print.js" />
            <h:form>
                <p:growl id="growl" showDetail="true" sticky="true" /> 
                <ul class="thumbnails">
                    <li class="span6">
                        <h:commandLink action="#{billConfirmController.exporter}" styleClass="exbutton" value="موردين">
                        </h:commandLink>
                    </li>
                    <li class="span6">
                        <h:commandLink action="#{billConfirmController.customer}" styleClass="cubutton" value="عملاء">
                        </h:commandLink>
                    </li>
                </ul>
            </h:form>

            <h:form id="form">
                <center>
                    <h1><h:outputText value="#{billConfirmController.title}"></h:outputText> </h1>
                </center>
                <h:panelGroup id="messagePanel" layout="block">
                    <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
                </h:panelGroup>

                <h:panelGroup rendered="#{billConfirmController.items.rowCount > 0}">
                    <p:dataTable id="mytable" value="#{billConfirmController.items}" var="item"
                                 paginator="true" rows="100"  
                                 paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
                                 rowsPerPageTemplate="100,200,300">
                        <p:column>
                            <f:facet name="header"> <h:selectBooleanCheckbox onchange='SelectAllCheckboxesSpecific(this)'>
                                </h:selectBooleanCheckbox>
                            </f:facet>

                            <h:selectBooleanCheckbox  value="#{billConfirmController.checked[item.idBill]}"/>
                        </p:column>
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="رقم الفاتوره"/>
                            </f:facet>
                            <h:outputText value="#{item.billNumber}"/>
                        </p:column>

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="رقم الدافتر"/>
                            </f:facet>
                            <h:outputText value="#{item.docNum}"/>
                        </p:column>

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListBillTitle_createDate}"/>
                            </f:facet>
                            <h:outputText value="#{item.createDate}">
                                <f:convertDateTime pattern="dd/MM/yyyy" />
                            </h:outputText>
                        </p:column>

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListBillTitle_billTotal}"/>
                            </f:facet>
                            <h:outputText value="#{item.billTotal}"/>
                        </p:column>

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListBillTitle_billCach}"/>
                            </f:facet>
                            <h:outputText value="#{item.billCach}"/>
                        </p:column>

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListBillTitle_billReminder}"/>
                            </f:facet>
                            <h:outputText value="#{item.billReminder}"/>
                        </p:column>

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListBillTitle_disCount}"/>
                            </f:facet>
                            <h:outputText value="#{item.disCount}"/>
                        </p:column>

                        <p:column>
                            <h:panelGroup rendered="#{billConfirmController.type==0}">
                                <f:facet name="header">
                                    <h:outputText value="#{bundle.ListBillTitle_customerID}"/>
                                </f:facet>
                                <h:outputText value="#{item.customerID.customerName}"/>
                            </h:panelGroup>
                            <h:panelGroup rendered="#{billConfirmController.type==1}">
                                <f:facet name="header">
                                    <h:outputText value="#{bundle.ListBillTitle_exporterID}"/>
                                </f:facet>
                                <h:outputText value="#{item.exporterID.exporterName}"/>
                            </h:panelGroup>
                        </p:column>

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="&nbsp;"/>
                            </f:facet>
                            <h:panelGroup rendered="#{billConfirmController.type==0}">
                                <h:commandButton action="#{billConfirmController.confirm(item)}" value="تاكيد" styleClass="btn btn-primary"/>
                            </h:panelGroup>
                            <h:panelGroup rendered="#{billConfirmController.type==1}">
                                <h:commandButton  action="#{billConfirmController.exporterConfirm(item)}" value="تاكيد" styleClass="btn btn-primary"/>
                            </h:panelGroup>
                            <h:outputText value=" "/>
                            <h:commandButton action="#{billConfirmController.destroy}" value="#{bundle.ListBillDestroyLink}" styleClass="btn btn-primary"/>
                        </p:column>
                    </p:dataTable>
                </h:panelGroup>
                <div class="form-inline">
                    <label style="padding-left: 10px; padding-right: 300px;" for="input13">إجمالى الفواتير</label>
                    <h:outputText value="#{billConfirmController.total}"/>
                    <label style="padding-left: 10px; padding-right: 20px;" for="input14">إجمالى المدفوع</label>
                    <h:outputText value="#{billConfirmController.cach}"/>
                    <label style="padding-left: 10px; padding-right: 20px;" for="input15">إجمالى الباقى</label>
                    <h:outputText value="#{billConfirmController.remin}"/>
                </div>
                <center>
                    <h:panelGroup rendered="#{billConfirmController.type==0}">
                        <h:commandButton value=" تاكيد الفواتير المختاره" action="#{billConfirmController.confirmSelected}" styleClass = "btn btn-primary" />
                    </h:panelGroup>
                    <h:panelGroup rendered="#{billConfirmController.type==1}">
                        <h:commandButton value=" تاكيد الفواتير المختاره " action="#{billConfirmController.exporterConfirmSelected}" styleClass = "btn btn-primary" />
                    </h:panelGroup>
                </center>

            </h:form>
        </ui:define>
    </ui:composition>
</html>
